<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- 计算属性 -->
        {{fullName}}
        <!-- 方法调用 -->
        <!-- {{fullName()}} -->
    </div>
</body>
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<script>
    var app = new Vue({
        el:"#app",
        data(){
            return {
                firstName:"rui",
                lastName:"jie",
                // fullName:"rui jie"
            }
        },
        //  方法调用 无有缓存机制
        methods: {
            // fullName:function(){
            //     return this.firstName+ " " + this.lastName;
            // }
        },
        //  计算属性 有缓存机制
        computed:{
            // fullName:function(){
            //     return this.firstName+ " " + this.lastName;
            // }
            fullName:{
                get(){
                    return this.firstName+" "+this.lastName;
                },
                set(value){
                    console.log(value);
                    var arr = value.split(" ");
                    this.firstName = arr[0];
                    this.lastName = arr[1];
                }
            }
        }
    })
</script>
</html>